home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5164 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: po.CWRU.Edu!mab22
  2. From: mab22@po.CWRU.Edu (Michael A. Balfour)
  3. Newsgroups: comp.lang.c
  4. Subject: Config files and ANSI C
  5. Date: 7 Feb 1996 23:31:01 GMT
  6. Organization: Case Western Reserve University, Cleveland, OH (USA)
  7. Message-ID: <4fbcnl$c2s@madeline.INS.CWRU.Edu>
  8. Reply-To: mab22@po.CWRU.Edu (Michael A. Balfour)
  9. NNTP-Posting-Host: kanga.ins.cwru.edu
  10.  
  11.  
  12. Are there any C (ANSI) routines available to read and write configuration
  13. files similar to an *.INI file?  I'm sure this question is a common one,
  14. but I haven't found any answers to it yet.  Here's an example of the
  15. type of file I'd like to read in:
  16.  
  17. [table1]
  18. name="Employee"
  19. numFields=1
  20.     [field1]
  21.     name="SSN"
  22.     type=NUMBER
  23.     [end field1]
  24. [end table1]
  25.  
  26. [table2]
  27. name="Company"
  28. numFields=1
  29.  
  30.     [field1]
  31.     name="TIN"
  32.     type=NUMBER
  33.     [end field1]
  34. [end table2]
  35.  
  36. As you can see, there's a need to access nested structures, as well as
  37. different data types.
  38.  
  39. I've approached the problem as possibly reading in the entire file into
  40. a buffer and doing strcmp's, but that seems rather time-consuming.  I've
  41. also seen someone refer to "XDR" as a means of writing cross-platform
  42. data files, but I can't find any information on that.  Basically, I'm
  43. trying not to re-invent the wheel in a worse way if I can avoid it. :)
  44.  
  45. If possible, please respond via e-mail as well as posting, because I
  46. don't have the chance to check this group often.
  47.  
  48. Thanks,
  49.  
  50. Mike Balfour
  51. -- 
  52. ----------------------------------+--------------------------------
  53. Mike Balfour, Partner             | BS/MS Candidate - ECMP
  54. Overload Engineering              | Case Western Reserve University
  55. "New Ideas for a Brighter Future" | Cleveland, OH
  56.